package com.htu.controller;

import com.htu.po.Orders;
import com.htu.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    @RequestMapping("/createOrders")
    public int createOrders(String userId ,Integer businessId , Integer daId){
       int rows = ordersService.createOrders(userId,businessId,daId);
       return rows;
    }
    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId){
        return ordersService.getOrdersById(orderId);

    }
    @RequestMapping("/listOrderByUserId")
    public List<Orders> listOrderByUserId(String userId){
        List<Orders> list = ordersService.listOrderByUserId(userId);
        return list;
    }
    @RequestMapping("/updateOrderStateByOrderId")
    public int updateOrderStateByOrderId(int orderId){
        return ordersService.updateOrderStateByOrderId(orderId);
    }
}
